package com.jt.tenant.adapter;

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.jt.tenant.R;
import com.jt.tenant.activity.ExpenseDetailActivity;
import com.jt.tenant.app.JTApplication;
import com.jt.tenant.conn.Get4SShopList;

import java.util.List;


/**
 * Created by Administrator on 2016/2/16.
 */
public class YearAdapter extends BaseAdapter {

    private LayoutInflater layoutInflater;

    private List<ExpenseDetailActivity.YearModel> list;

    public YearAdapter(Context context, List<ExpenseDetailActivity.YearModel> list) {

        layoutInflater = ((Activity) context).getLayoutInflater();

        this.list = list;

    }

    @Override
    public int getCount() {

        return list.size();

    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder holder = null;

        if (convertView == null) {

            convertView = JTApplication.ScaleScreenHelper.loadView((ViewGroup) layoutInflater.inflate(R.layout.item_year, null));

            holder = new ViewHolder();

            holder.item_name = (TextView) convertView.findViewById(R.id.text_item_year);

            convertView.setTag(holder);

        } else {

            holder = (ViewHolder) convertView.getTag();

        }
        if(list.get(position).flag.equals("1")){
            holder.item_name.setTextColor(Color.parseColor("#ff6565"));
        }else{
            holder.item_name.setTextColor(Color.parseColor("#4b4b4b"));
        }
        if(list.get(position).type.equals("0")){
            if(list.get(position).id.equals("-1"))
                holder.item_name.setText(list.get(position).text);
            else
            holder.item_name.setText(list.get(position).text + "年");
        }
        else{
            if(list.get(position).id.equals("-2"))
                holder.item_name.setText(list.get(position).text);
            else
            holder.item_name.setText(list.get(position).text + "月");
        }


        return convertView;

    }

    private class ViewHolder {

        private TextView item_name;

    }

}
